let iptAll = document.querySelectorAll("main .consultBox .container .info_form input");
let iptEmail = document.querySelector("main .consultBox .container .info_form .ipt_email input");
let submit = document.querySelector("main .consultBox .container .submit");
let getCode = document.querySelector("main .consultBox .container .info_form .ipt_code button");
// 这个开关用来判断什么时候显示蓝色边框
let flag = true;
getCode.addEventListener("click", function (e) {
    e.preventDefault()
})
iptAll.forEach(function (item) {
    item.addEventListener("focus", function (e) {
        if (flag) {
            e.target.style.borderColor = "skyblue";
        }
    })
    item.addEventListener("blur", function (e) {
        e.target.style.borderColor = "#dcdfe6";
        e.target.previousElementSibling.style.display = "none";
        flag = true;
        if (e.target.value === "") {
            e.target.style.borderColor = "#f56c6c";
            e.target.previousElementSibling.style.display = "block";
            flag = false;
            // console.log(e.target.nextElementSibling);
        }
    })
})
submit.addEventListener("click", function () {
    iptAll.forEach(function (item) {
        if (item.value === "") {
            item.style.borderColor = "#f56c6c";
            item.previousElementSibling.style.display = "block";
            flag = false;
        }
    })
})
// iptEmail.addEventListener("input", function () {
//     let reg = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/g;
//     if (reg.test(iptEmail.value)) {
//         iptEmail.style.borderColor = "skyblue";
//         iptEmail.previousElementSibling.style.display = "none";
//     } else {
//         iptEmail.style.borderColor = "#f56c6c";
//         iptEmail.previousElementSibling.style.display = "block";
//         iptEmail.previousElementSibling.innerHTML = "请输入正确的邮箱";
//     }
// })